/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package br.ufrn.dca.Comunicacao;

import br.ufrn.dca.controle.QuanserClient;
import br.ufrn.dca.controle.QuanserClientException;

/**
 *
 * @author allan
 */
public class Cliente {

    private QuanserClient qc;
    private String servidor;
    private double ks;
    private int portaDeComunicacao;

    public Cliente(String servidor, int portaDeComunicacao) {
        this.ks = 6.25;
        this.qc = null;
        this.servidor = servidor;
        this.portaDeComunicacao = portaDeComunicacao;
    }

    public void conectar() throws QuanserClientException {
        this.qc = new QuanserClient(servidor,portaDeComunicacao);
    }

    public double getNivelTanque2() throws QuanserClientException {
        return (qc.read(1) * ks);
    }

    public double getNivelTanque1() throws QuanserClientException {
        return (qc.read(0) * ks);
    }
    
    public void enviarSinal (double sinalEscrito) throws QuanserClientException{
        qc.write(0, sinalEscrito);
    }
}
